home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_218 / edlib / strpos.c < prev    next >
Text File  |  1992-05-06  |  632b  |  29 lines

  1. /*
  2.  * edlib v1.1 Copyright 1989 Edwin Hoogerbeets
  3.  * This code is freely redistributable as long as no charge other than
  4.  * reasonable copying fees are levied for it.
  5.  */
  6.  
  7. /*
  8.     strpos searches the null-terminated string string for the first
  9.     occurance of the character "key". It returns either the position
  10.     or EOF if it is not found.
  11. */
  12.  
  13. int strpos(string,key)
  14. register char *string;
  15. register char key;
  16. {
  17.     register int counter = 0;
  18.  
  19.     if ( !key )
  20.         return(strlen(string));
  21.  
  22.     while (string[counter]) {
  23.         if (string[counter] == key)
  24.             return(counter);
  25.         counter++;
  26.     }
  27.     return(-1);
  28. }
  29.